package com.dragon.repository.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dragon.repository.entity.ProduceScheduling;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 生产的排产表 Mapper 接口
 * </p>
 *
 * @author sy
 * @since 2023-11-29
 */
@Mapper
public interface ProduceSchedulingMapper extends BaseMapper<ProduceScheduling> {

    @Select("<script>" +
            "SELECT M.* from ( " +
            "SELECT dps.*, de.img as equipmentImg, de.equipment_code as equipmentCode, de.type as equipmentType " +
            "FROM dragon_produce_scheduling dps " +
            "LEFT JOIN dragon_equipment de on dps.equipment_id = de.id )M WHERE 1=1 " +
            "<if test='type != null and search != \"\"'> "+
            " and M.type = #{type}  " +
            "</if> " +
            "</script>")
    Page<ProduceScheduling> selectDetailList(Page<ProduceScheduling> schedulePage, Integer type);

    @Select("select dps.* from dragon_produce_scheduling dps " +
            "where dps.produce_id = #{produceId}")
    List<ProduceScheduling> selectListByProduceId(Integer produceId);


}
